package com.hzcc.hzccblog.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author 早睡蛋
 * @Date 2022/6/6 16:35:01
 * @Desc:静态资源配置类
 */

@Configuration
public class StaticConfig implements WebMvcConfigurer {

    @Value("${articleImages.dir}")
    private String articleImages;
    @Value("${myAvator.dir}")
    private String myAvator;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        //文章图片
        registry.addResourceHandler("/article/images/**").addResourceLocations(
                "file:"+articleImages
        );
        //头像
        registry.addResourceHandler("/myAvator/**").addResourceLocations(
                "file:"+myAvator
        );
    }
}
